package indi.zhang.simplemqconsumer.listener;

import indi.zhang.mq.MessageContent;
import indi.zhang.rocketmq.listener.TLogListener;
import indi.zhang.simplemqconsumer.service.TestAsyncService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
@RequiredArgsConstructor
@RocketMQMessageListener(topic = "TEST",
        consumerGroup = "test",
        consumeMode = ConsumeMode.ORDERLY)
public class TestListener extends TLogListener {

    private final TestAsyncService testAsyncService;

    @Override
    public void deal(MessageContent data) {
        log.info("数据内容是：{}",data);
        for (int i = 0; i < 10; i++) {
            testAsyncService.async();
        }
    }
}
